|
|
|
|
|
|
|
lTemp = MoveToEx(hdc, 0, Item.Top, pointx)
lTemp = LineTo(hdc, .Width, Item.Top)
lTemp = MoveToEx(hdc, 0, Item.Top + nHeight, pointx)
lTemp = LineTo(hdc, .Width, Item.Top + nHeight)
lTemp = ReleaseDC(.hwnd, hdc)
End With
End Sub |
|
|
|
|
|
|
|
|
The code in Listing 19.1 demonstrates one of the basic concepts of using graphics API calls: the device context. A device context can be used by other graphics API calls to draw on an object. The example uses the GetDC API call to determine the device context for the ListView control and then uses the LineTo API call to draw on the ListView control. |
|
|
|
|
|
|
|
|
Working with Text and Fonts |
|
|
|
|
|
|
|
|
To write almost any program in Visual Basic, you need to know how to work with text. In earlier chapters, you learned something about displaying text in labels and text boxes. You also learned about string functions used to manipulate text in code. This chapter will expand on that knowledge by showing you how to display text in a way that is most intuitive to the users of your programs. |
|
|
|
|
|
|
|
|
In Chapter 4, "Using Visual Basic's Default Controls," you were introduced to the text box. You already know that the Text property is used to store and retrieve information. In addition to the standard properties discussed in that chapter, several other properties make the TextBox control even more versatile: |
|
|
|
|
|
|
|
|
Locked. This property prevents the users from entering information in the text box. |
|
|
|
|
|
|
|
|
MaxLength. This property limits the number of characters that the text box can accept. |
|
|
|
|
|
|
|
|
PasswordChar. This property causes the text box to hide the information typed by the users. |
|
|
|
|
|
|
|
|
SelLength, SelStart, and SelText. These properties allow the users to manipulate only the selected (highlighted) part of the text in the text box. |
|
|
|
|
|
|
|
|
First, take a look at the Locked property, which allows you to use a text box for display only. The obvious question is why would you want to do that instead of just using a Label control? The answer is that although a locked text box does not allow users to update it, they still can scroll, select, and copy text. Of course, program code can always modify text in a text box whether or not it is locked. To lock a text box, simply set the Locked property to True, as in the following examples: |
|
|
|
|
|
|
|
|
'LOCKS A SINGLE TEXT BOX
txtTest.Locked = True
txtTest.Text = "You can't edit this!" |
|
|
|
|
|